Skip to content

Conversation

sunyuhan1998
Copy link
Contributor

As mentioned in the issue #3998 , when OllamaChatModel constructs the OllamaApi.ChatRequest, it directly uses instanceof to identify the Message type. This approach restricts users from customizing their own implementations of AbstractMessage and is also inconsistent with the implementation of other ChatModels (e.g., org.springframework.ai.openai.OpenAiChatModel#createRequest and org.springframework.ai.deepseek.DeepSeekChatModel#createRequest).

This PR resolves the issue by unifying the implementation: message type identification is now performed using MessageType.

Fixes #3998

…ama.OllamaChatModel#ollamaChatRequest` to support custom implementations of `AbstractMessage` and align with other `ChatModel` implementations.

Signed-off-by: Sun Yuhan <[email protected]>
@sunyuhan1998 sunyuhan1998 changed the title refactor: GH-3998 Refactor `org.springframework.ai.ollama.OllamaChatM… fix: GH-3998 Refactor `org.springframework.ai.ollama.OllamaChatM… Aug 5, 2025
@sunyuhan1998 sunyuhan1998 changed the title fix: GH-3998 Refactor `org.springframework.ai.ollama.OllamaChatM… fix: GH-3998 Refactor the ollamaChatRequest method of OllamaChatModel Aug 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OllamaChatModel doesn't respect custom AbstractMessage's implementation
1 participant